import 'package:flutter/material.dart';
import 'package:yuque/app_theme.dart';

class ActionItem extends StatelessWidget {
  const ActionItem({Key? key, this.onTap, this.leading, this.tail, this.tailDescription}) : super(key: key);

  final VoidCallback? onTap;
  final Widget? leading;
  final Widget? tail;
  final String? tailDescription;

  @override
  Widget build(BuildContext context) {
    Widget _tail = Row(
      children: [
        if (tailDescription != null)
          Text(
            tailDescription!,
            style: TextStyle(
              color: AppTheme.lightGrey,
            ),
          ),
        SizedBox(width: 5),
        if (onTap != null)
          Icon(
            Icons.arrow_forward_ios,
            color: AppTheme.lightGrey,
            size: 15,
          ),
      ],
    );
    if (tail != null) {
      _tail = tail!;
    }
    return GestureDetector(
      onTap: onTap,
      child: Container(
        padding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
        color: Colors.white,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            if (leading != null) leading!,
            _tail,
          ],
        ),
      ),
    );
  }
}
